package com.laotou99.wmsjjj.wmsjjj;

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.laotou99.wmsjjj.wmsjjj.service.LOCService;

@RunWith(SpringRunner.class)
@SpringBootTest
public class WmsjjjALLOCTest3 {
	
	@Autowired
	LOCService locService;

	@Test
	public void contextLoads() {
		System.out.println("first load");
	}
	
	@Before
	public void before() {
		System.out.println("before");
	}
	
	@After
	public void after() {
		System.out.println("after()");
	}
	
	@Test
	public void showAllLoc() {//显示所有的库位
		String showAllLoc = locService.showAllLoc();
		System.out.println("showAllLoc-=>"+JSON.toJSONString(showAllLoc));
		assertEquals(1+1, 2);
	}
	
	@Test
	public void showList() {//显示页面库位
		System.out.println("showList()");
		JSONObject jo1 = new JSONObject();
		try {

			String listLoc = locService.showList(jo1);
			System.out.println("listLoc-=>"+listLoc);
				
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
	}
	
	
	//新增库位
	@Test
	public void addNew() {
		System.out.println("addNew()");
		JSONObject jo1 = new JSONObject();
		
		jo1.put("locId","11");
		jo1.put("locNum","测试编号1");
		jo1.put("locName","测试库位名");
		jo1.put("locType","测试库位类型");
		jo1.put("locVol","1111");
		jo1.put("usedVol","1");
		jo1.put("status","N");
		//jo1.put("createDate","");
		//jo1.put("modifyDate","");
		jo1.put("skuName","测试品名");
		jo1.put("remark1","测试备注1");
		jo1.put("remark2","测试备注2");
		jo1.put("remark3","测试备注3");
		jo1.put("remark4","测试备注4");
		jo1.put("remark4","测试备注5");
		jo1.put("remark6","测试备注6"); 
		
		
		try {
			String result = locService.addNew(jo1);
			System.out.println("addNew() result-=>"+result);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		} 
		assertEquals(1+1, 2);
	}
//{"createDate":1745773846760,"id":10,"locId":10,"locName":"测试库位名","locNum":"测试编号1","locType":"测试库位类型","locVol":1111,"modifyDate":1745773846760,"remark1":"测试备注1","remark2":"测试备注2","remark3":"测试备注3","remark4":"测试备注5","remark6":"测试备注6","skuName":"测试品名","status":"N","usedVol":1}
	
	//修改库位
	@Test
	public void update() {
		System.out.println("update()");
		
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 11);
//		jo1.put("locNum", "测试编号1a");
//		jo1.put("locName", "测试库位名a");
//		jo1.put("locType", "测试库位类型2b");
//		jo1.put("locVol", 2222);
//		jo1.put("skuName", "复习册");
//		jo1.put("locId", 12312);
//		jo1.put("usedVol", 2);
		
		try {

			String result = locService.selectById(jo1);
			
			JSONObject jo2 = JSON.parseObject(result);
			jo2.put("locNum", "测试编号1a");
			jo2.put("locName", "测试库位名a");
			jo2.put("locType", "测试库位类型2b");
			jo2.put("locVol", 2222);
			jo2.put("skuName", "复习册");
			jo2.put("locId", 12312);
			jo2.put("usedVol", 2);
			
			String result2 = locService.update(jo2);
			System.out.println("update result-=>"+result2);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		assertEquals(1+1, 2);
	}
	
	//删除库位
	@Test
	public void delete() {
		System.out.println("delete()");
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 10);
		
		try {
			
			String result = locService.delete(jo1);
			System.out.println("result-=>"+result);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		assertEquals(1+1, 2);
	}
	
	//锁住库位
	@Test
	public void lockLoc() {
		assertEquals(1+1, 2);
	}
	
	//解锁库位
	@Test
	public void unlockLoc() {
		assertEquals(1+1, 2);
	}
	
	//根据ID查找
	@Test
	public void selectById() {
		System.out.println("selectById()");
		
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 11);
		
		try {
			String result = locService.selectById(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}	
		assertEquals(1+1, 2);	
	}

}
